<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/vue-router-2.7.0.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			<router-link to="/login">登录</router-link>
			<router-link to="/register">注册</router-link>
			<router-view></router-view>
		</div>
		<script type="text/javascript">
			var login={template:"<h3>登录组件</h3>"}
			var register={template:"<h3>注册组件</h3>"}
			
			var router= new VueRouter({
				routes:[
					{path:"/login",component:login},
					{path:"/register",component:register}
				]
			})
			
			new Vue({
				el:"#app",
				router,
				watch:{
					'$route.path':function(newVal,oldVal){
						console.log(newVal)
						if(newVal==='/login'){
							console.log('欢迎来到登录联盟')
						}else if(newVal==='/register'){
							console.log('欢迎来到注册联盟')
						}
					}
				}
			});
		</script>
	</body>
</html>
